package com.jason.shader.view;

import android.content.Context;
import android.graphics.Camera;
import android.graphics.Canvas;
import android.graphics.Matrix;
import android.util.AttributeSet;
import android.widget.ListView;

/**
 *
 * @DESC: 使用Camare让listview看起来像倒下去一样
 * @Author: Jason
 * @Date: 16/9/9
 * @Time: 14:16
 */

public class AnimListView8 extends ListView {

    private Camera mCamera;
    private Matrix mMatrix;


    public AnimListView8(Context context, AttributeSet attrs) {
        super(context, attrs);

        mCamera = new Camera();
        mMatrix = new Matrix();

    }

    @Override
    protected void onDraw(Canvas canvas) {
        mCamera.save();
        mCamera.rotate(30, 0, 0);
        mCamera.getMatrix(mMatrix);
        mMatrix.preTranslate(-getWidth() / 2, -getHeight() / 2);
        mMatrix.postTranslate(getWidth() / 2, getHeight() / 2);
        canvas.concat(mMatrix);
        super.onDraw(canvas);
        mCamera.restore();

    }
}
